
package ch.hearc.meteo.imp.afficheur.real.vue.atome;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.util.ArrayList;

import javax.swing.JPanel;
import javax.swing.JTable;

import ch.hearc.meteo.imp.afficheur.real.JFrameStationMeteo;
import ch.hearc.meteo.imp.afficheur.real.moo.MeteoTableCellRenderer;
import ch.hearc.meteo.imp.afficheur.real.moo.MeteoTableHeaderRenderer;
import ch.hearc.meteo.imp.afficheur.real.moo.MeteoTableModel;
import ch.hearc.meteo.imp.afficheur.real.moo.StationMeteoElement;
import ch.hearc.meteo.tools.ImageShop;

public class JPanelStationMeteoActInfo extends JPanel
	{

	/*------------------------------------------------------------------*\
	|*							Constructeurs							*|
	\*------------------------------------------------------------------*/

	public JPanelStationMeteoActInfo(ArrayList<StationMeteoElement> listStationMeteoElements)
		{
		this.listStationMeteoElements = listStationMeteoElements;
		geometry();
		control();
		apparence();
		}

	/*------------------------------------------------------------------*\
	|*							Methodes Public							*|
	\*------------------------------------------------------------------*/

	public void meteoDataChanged()
		{
		try
			{
			meteoTableModel.fireTableDataChanged();
			}
		catch (Exception e)
			{

			}
		this.repaint();
		}

	/*------------------------------*\
	|*				Set				*|
	\*------------------------------*/

	/*------------------------------*\
	|*				Get				*|
	\*------------------------------*/

	/*------------------------------------------------------------------*\
	|*							Methodes Private						*|
	\*------------------------------------------------------------------*/
	private void apparence()
		{
		tableStationMeteo.setBackground(JFrameStationMeteo.COLOR_S3);
		}

	private void control()
		{

		}

	private void geometry()
		{
		this.setLayout(new BorderLayout());
		meteoTableModel = new MeteoTableModel(listStationMeteoElements);
		tableStationMeteo = new JTable(meteoTableModel);

		meteoTableCellRenderer = new MeteoTableCellRenderer();
		tableStationMeteo.setDefaultRenderer(Object.class, meteoTableCellRenderer);
		tableStationMeteo.getTableHeader().setPreferredSize(new Dimension(200, 40));
		tableStationMeteo.getTableHeader().setMinimumSize(new Dimension(200, 40));
		tableStationMeteo.getTableHeader().getColumnModel().getColumn(0).setHeaderRenderer(new MeteoTableHeaderRenderer(null));
		tableStationMeteo.getTableHeader().getColumnModel().getColumn(1).setHeaderRenderer(new MeteoTableHeaderRenderer(ImageShop.IMAGE_ALTITUDE));
		tableStationMeteo.getTableHeader().getColumnModel().getColumn(2).setHeaderRenderer(new MeteoTableHeaderRenderer(ImageShop.IMAGE_PRESSURE));
		tableStationMeteo.getTableHeader().getColumnModel().getColumn(3).setHeaderRenderer(new MeteoTableHeaderRenderer(ImageShop.IMAGE_TEMPERATURE));
		this.add(tableStationMeteo.getTableHeader(), BorderLayout.PAGE_START);
		this.add(tableStationMeteo, BorderLayout.CENTER);

		}

	/*------------------------------------------------------------------*\
	|*							Attributs Private						*|
	\*------------------------------------------------------------------*/
	private JTable tableStationMeteo;
	private MeteoTableModel meteoTableModel;
	private MeteoTableCellRenderer meteoTableCellRenderer;
	private ArrayList<StationMeteoElement> listStationMeteoElements;
	//public static final String[] COLUMN_NAMES = { "Nom", "Altitude", "Pression", "Temp�rature" };
	}
